package com.easylinkin.linkappapi.config.vo;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.easylinkin.linkappapi.config.entity.SysDict;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

/**
 * @author chenyin
 * @date 2024/02/18
 */
@Getter
@Setter
@ToString
public class SysDictQueryRequestVo {

    /**
     * 字典名称
     */
    private String dictName;
    /**
     * 字典编码
     */
    private String dictCode;
    /**
     * 描述
     */
    private String description;

    public Wrapper<SysDict> getQueryWrapper() {
        LambdaQueryWrapper<SysDict> qw = Wrappers.lambdaQuery();
        qw.like(StringUtils.isNotEmpty(dictName), SysDict::getDictName,dictName)
                .like(StringUtils.isNotEmpty(dictCode), SysDict::getDictCode,dictCode)
                .orderByDesc(SysDict::getCreateTime);
        return qw;
    }

    public SysDict toEntity() {
        SysDict sysDict = new SysDict();
        sysDict.setDictName(dictName);
        sysDict.setDictCode(dictCode);
        sysDict.setDescription(description);
        return sysDict;
    }

}